jsx3.Class.defineClass(
        "tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent.overview.Overview", //the full name of the class to create
        jsx3.lang.Object, //  extends
        [tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceTabInterface, tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceInstanceTabInterface], // implements
        function (plugin) {
        
			plugin.instance = null;
			
			plugin.prototype.isServiceInstanceMode = false;			
			plugin.prototype.overviewBlock;
			plugin.prototype.performBrowseHide;

            plugin.getInstance = function(args) {
                if(!this.instance) {
                    this.instance = new tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent.overview.Overview();
                }
                return this.instance;
            }

            plugin.prototype.getNamespace = function() {
               return "tibco.admin";
            }
            
            plugin.getTabText = function() {
				return tibco.admin.Main.getServer().getDynamicProperty("@MM@general@OverviewTitle");
            	//return "Overview";
            }
            
            plugin.prototype.getTabText = function() {
				return tibco.admin.Main.getServer().getDynamicProperty("@MM@general@OverviewTitle");
            	//return "Overview";
            }
            
            plugin.prototype.updateComponent = function(serviceId) {
				jsx3.log("serviceId in overview = " + serviceId);
            }
            
            plugin.prototype.setIsServiceInstanceMode = function(isServiceInstanceMode) {
            	this.isServiceInstanceMode = isServiceInstanceMode;
            }

            plugin.prototype.loadComponent = function(parent) {
            	tibco.admin.monitormanage.general.PageBusUtils.subscribe(tibco.admin.monitormanage.uicomponents.misc.browseWindowShade.BrowseWindowShade.browseOpenCloseSubject, this.handleBrowseOpenClose, this);
            	tibco.admin.monitormanage.general.PageBusUtils.subscribe(tibco.admin.monitormanage.general.NavigationHandler.mainPageDisplayTopic, this.handleDisplayScreen, this);
            
                this.overviewBlock = tibco.admin.Main.loadUIResource(parent, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/page/serviceView/tabContent/overview/components/overview.xml", true);
                this.performBrowseHide = false;
                
                var infoPane = this.overviewBlock.getDescendantOfName("overviewInfoPane");
        		if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.text || !tibco.admin.monitormanage.uicomponents.text.serviceOverviewInfo || !tibco.admin.monitormanage.uicomponents.text.serviceOverviewInfo.ServiceOverviewInfo)
                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/text/serviceOverviewInfo/ServiceOverviewInfo.js", this.getNamespace()); }
                var infoPaneObj = tibco.admin.Main.loadUIResource(infoPane, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/text/serviceOverviewInfo/components/serviceOverviewInfo.xml", true);
                infoPaneObj.setUpComponent(this.isServiceInstanceMode);

                var requestsChartPane = this.overviewBlock.getDescendantOfName("overviewTopRightPane");
        		if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.chart || !tibco.admin.monitormanage.uicomponents.chart.serviceRequests || !tibco.admin.monitormanage.uicomponents.chart.serviceRequests.ServiceRequests)
                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/chart/serviceRequests/ServiceRequests.js", this.getNamespace()); }
                var requestsChart = tibco.admin.Main.loadUIResource(requestsChartPane, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/chart/serviceRequests/components/serviceRequests.xml", true);   
                var chartId = "serviceOverviewTabRequestsChartId";
                if(this.isServiceInstanceMode)
                { chartId = "serviceInstanceOverviewTabRequestsChartId"; }
                requestsChart.setUpComponent(chartId, this.isServiceInstanceMode);

                var performancePane = this.overviewBlock.getDescendantOfName("overviewBottomRightPane");
        		if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.misc || !tibco.admin.monitormanage.uicomponents.misc.servicePerformance || !tibco.admin.monitormanage.uicomponents.misc.servicePerformance.ServicePerformance)
                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/misc/servicePerformance/ServicePerformance.js", this.getNamespace()); }
                var performanceModel = tibco.admin.Main.loadUIResource(performancePane, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/misc/servicePerformance/components/servicePerformance.xml", true);   
                performanceModel.loadComponent(this.isServiceInstanceMode);
				
				var requestsPiePane = this.overviewBlock.getDescendantOfName("pieBlock");
        		if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.chart || !tibco.admin.monitormanage.uicomponents.chart.serviceRequestsPie || !tibco.admin.monitormanage.uicomponents.chart.serviceRequestsPie.ServiceRequestsPie)
                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/chart/serviceRequestsPie/ServiceRequestsPie.js", this.getNamespace()); }
                var requestsPieModel1 = tibco.admin.Main.loadUIResource(requestsPiePane, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/chart/serviceRequestsPie/components/serviceRequestsPie.xml", true);   
                var chartId = "serviceRequestsPieChartId1";
                if(this.isServiceInstanceMode)
                { chartId = "serviceInstanceRequestsPieChartId1"; }
                requestsPieModel1.setUpComponent(chartId, true, this.isServiceInstanceMode);
                
                var requestsPieModel2 = tibco.admin.Main.loadUIResource(requestsPiePane, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/chart/serviceRequestsPie/components/serviceRequestsPie.xml", true);   
                chartId = "serviceRequestsPieChartId2";
                if(this.isServiceInstanceMode)
                { chartId = "serviceInstanceRequestsPieChartId2"; }
                requestsPieModel2.setUpComponent(chartId, false, this.isServiceInstanceMode);
               this.overviewBlock.getDescendantOfName("performanceHelpImg").setEvent("this.getAncestorOfName('performanceBlk').performanceHelpImgClicked(objEVENT)", "jsxexecute");
               this.overviewBlock.getDescendantOfName("faultsuccessHelpImg").setEvent("this.getAncestorOfName('performanceBlk').faultsuccessHelpImgClicked(objEVENT)", "jsxexecute");

            }
            
            plugin.prototype.handleDisplayScreen = function(subject, message, overviewObj) {
            	if(!overviewObj.isServiceInstanceMode && message.screenId == tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceView.serviceScreenId)
            	{ overviewObj.performBrowseHide = true; }
            	else if(overviewObj.isServiceInstanceMode && message.screenId == tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceView.serviceInstanceScreenId)
            	{ overviewObj.performBrowseHide = true; }
            }
            
            plugin.prototype.handleBrowseOpenClose = function(subject, message, overviewObj) {
            	// hide the fusion chart if the browse window is open considering the fusion chart is heavy weight
            	var visibility;
            	if(overviewObj.performBrowseHide && message.browseOpen)
            	{ visibility = jsx3.gui.Block.VISIBILITYHIDDEN; }
            	else
            	{ visibility = jsx3.gui.Block.VISIBILITYVISIBLE; }
            	var requestsChartPane = overviewObj.overviewBlock.getDescendantOfName("overviewTopRightPane");
            	if(requestsChartPane.getVisibility() != visibility)
            	{ requestsChartPane.setVisibility(visibility, true); }
            }
            
            plugin.prototype.tabClicked = function(objEvent) {
            	var screenId;
            	if(this.isServiceInstanceMode)
            	{ screenId = tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceView.serviceInstanceScreenId; }
            	else
            	{ screenId = tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceView.serviceScreenId; }
            	tibco.admin.monitormanage.uicomponents.dropdown.timeframe.Timeframe.showTimeframe(screenId);
        	}

        });